package com.hudongwx.yuan_sdjj.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.hudongwx.yuan_sdjj.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_grid_browser)
public class GridBrowserActivity extends AppCompatActivity {
    @ViewInject(R.id.grid_browser_tv)
    private TextView textView;
    @ViewInject(R.id.grid_browser_wb)
    private WebView webView;
    private String TAG = "GridBrowserActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        String link = getIntent().getStringExtra("link");
        Log.i(TAG, "onCreate: "+link);
        //支持js
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return true;
            }
        });
        webView.setWebChromeClient(new WebChromeClient(){
            @Override
            public void onReceivedTitle(WebView view, String title) {
                //过得网页标题
                textView.setText(title);
            }
        });
        webView.loadUrl(link);
    }

    @Event(R.id.grid_browser_iv_back)
    private void goBack(View view){
        //注意用标注后的点击事件一定要有View 
        //继承父类的返回键
        super.onBackPressed();
    }

}
